package com.java.multipledatasource.spring.proxy;

import com.java.multipledatasource.spring.service.UserDao;
import org.apache.ibatis.annotations.Select;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author hu
 * @version 1.0
 * @date 2020/12/23 0023 下午 9:57
 * @description
 */
public class Test {
    public static void main(String[] args) {
//        ProxyFactory proxyFactory = new ProxyFactory();
//        proxyFactory.setTargetClass(UserDao.class);
//        proxyFactory.addAdvice((MethodBeforeAdvice) (method, objects, o) -> {
//            Select annotation = method.getAnnotation(Select.class);
//            System.out.println(Arrays.toString(annotation.value()));
//            method.invoke(objects, o);
//        });
        Action proxyAction =  new ProxyUserAction(new UserAction());
        proxyAction.action();
    }
}
